package com.example.demorabbitmq;

import com.alibaba.fastjson.JSON;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author liyh <levart@163.com>
 * @version 20210729
 */
@Service
public class MqService {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(MessageVO messageVO) {
        rabbitTemplate.convertAndSend(MqConfig.EXCHANGE, MqConfig.ROUTER_KEY, JSON.toJSONString(messageVO));
    }
}
